home *** CD-ROM | disk | FTP | other *** search
/ Atlas of Florida / Atlas of Florida.iso / Movies / 4.0 Population / 00001_Script_1 next >
Text File  |  1994-08-23  |  8KB  |  257 lines

  1. --
  2. --  Movie scripts version 1.3  -  6/7/94
  3. --  All scripts written by David May.
  4. --
  5.  
  6. on startMovie
  7.   
  8.   openXlib "PrintField XCMD"
  9.   openResFile "Atlas.rsrc"
  10.   readGlossary "Glossaries:4.0 glossary"
  11.   
  12.   set the keyDownScript = "checkKey"
  13. end startMovie
  14.  
  15.  
  16. on stopMovie
  17.   closeXlib "PrintField XCMD"
  18.   closeResFile "Atlas.rsrc"
  19. end stopMovie
  20.  
  21.  
  22. on checkKey                                  -- Checks for command-key combinations
  23.   global textOpen, currentOpen, textChannel
  24.   
  25.   if (the key = "p") and (the commandDown) and textOpen then
  26.     if currentOpen <> 0 then set textChannel = currentOpen
  27.     put the castNum of sprite textChannel into theNum
  28.     printText theNum
  29.   end if
  30.   
  31. end checkKey
  32.  
  33.  
  34. on setupText text,def                        -- This sets up the global variables and hides the proper channels
  35.   global textOpen, defChannel, textChannel   --    when using a single popup text field and definition field
  36.   
  37.   if (text=0) and (def=0) then
  38.     set textOpen=false
  39.     showChannel textChannel
  40.     showChannel defChannel
  41.     set textChannel = 0
  42.     set defChannel = 0
  43.   else
  44.     showChannel textChannel
  45.     showChannel defChannel
  46.     set textOpen = false
  47.     set textChannel = text
  48.     set defChannel = def
  49.     hideChannel textChannel
  50.     hideChannel defChannel
  51.   end if
  52.   
  53. end setupText
  54.  
  55.  
  56. on multiText  which                          -- This code handles multiple text fields on a page
  57.   global currentOpen, textOpen
  58.   
  59.   if currentOpen = which then
  60.     hideChannel which
  61.     updateStage
  62.     set currentOpen = 0
  63.     set textOpen = false
  64.     exit
  65.   end if
  66.   
  67.   if currentOpen <> 0 then hideChannel currentOpen
  68.   
  69.   showChannel which
  70.   set currentOpen = which
  71.   set textOpen to true
  72. end multiText
  73.  
  74.  
  75. on readText filename                         -- Reads in a text file "fileName" into "the result"
  76.   
  77.   set filename = the pathName & filename     -- Use the pathname of the movie + the desired name
  78.   set file = FileIO(mNew, "read", fileName)  -- Create a new instance of the FileIO XObject
  79.   
  80.   
  81.   if not objectp(file) then                  -- If the file couldn't be opened then exit gracefully.
  82.     return ""                                -- To do error checking, put a value in here
  83.   end if
  84.   
  85.   set s = file(mreadfile)                    -- Use our new object to read in the file
  86.   file(mDispose)                             -- Dispose of our file object
  87.   
  88.   if s <> "" then                            -- If there was any text in the file,
  89.     return s
  90.   else
  91.     return ""
  92.   end if
  93. end readText
  94.  
  95.  
  96. on writeText fileName, theField              -- Writes out a text file containing the contents of "theField"
  97.   
  98.   set file = FileIO(mNew, "?write", fileName)
  99.   
  100.   if not objectp(file) then
  101.     return false    
  102.   else    
  103.     set s = the text of field theField
  104.     file(mWriteString,s)    
  105.   end if
  106.   
  107.   file(mDispose)
  108.   
  109. end writeText
  110.  
  111.  
  112. on printText theField                        -- Prints out the text field with castNum of "theField"
  113.   
  114.   set aName = CallBackTracer(mNew)
  115.   SetCallBack PrintDoc, aName
  116.   
  117.   --parameter strings
  118.   set PageHeader = ""
  119.   set container = the text of cast theField
  120.   set PrintDialogString = ""
  121.   set FontName = "times"
  122.   set FontSize = "12"
  123.   set BooleanSetUp = "true"
  124.   
  125.   --command line
  126.   PrintDoc PageHeader, container, PrintDialogString, FontName, FontSize, BooleanSetUp
  127.   
  128.   
  129.   --this factory to bypass some message form the XCMD
  130. factory CallBackTracer
  131.   
  132. method mNew
  133. method mSendHCMessage x
  134. method mSendCardMessage x
  135.   
  136. end printText
  137.  
  138.  
  139. on readGlossary glossFile                    -- Reads in a glossary file into the global "gGlossary"
  140.   global gGlossary
  141.   readText glossFile
  142.   if (the result = "") then                  -- If an error occurred then,
  143.     alert "The glossary could not be found!" -- Display the appropriate error box.
  144.     put "" into gGlossary
  145.   else
  146.     put the result into gGlossary
  147.     return the result  
  148.   end if
  149. end readGlossary
  150.  
  151.  
  152. on readDefinition def                        -- Reads in the definition "def" from disk and puts it in the def. field
  153.   global defChannel
  154.   put the castNum of sprite defChannel into defField
  155.   readText "Definitions:" & def
  156.   if (the result = "") then                  -- If an error occurred then,
  157.     alert "The definition " & quote & def & quote & " could not be found!"
  158.     put empty into field defField
  159.     return false
  160.   else
  161.     put the result into field defField
  162.     return true
  163.   end if
  164. end readDefinition
  165.  
  166.  
  167. on waitForMouse
  168.   repeat while (not the mouseDown)           -- Loop until the mouse is clicked
  169.   end repeat
  170.   
  171.   openXLib "Johnny.xobj"                     -- Use the XObject "Johnny" to flush the event queue
  172.   set myFlush=johnny(mnew)                   -- so that Director won't recieve the mouse click
  173.   myflush(mflush)
  174.   myflush(mdispose)
  175.   closeXLib "Johnny.xobj"
  176. end waitForMouse
  177.  
  178.  
  179. on removePunc theWord                                        -- Will strip out the characters in "puncMarks" from "theWord"
  180.   
  181.   put ".!?,();:" & return & quote into puncMarks             -- faster this way
  182.   
  183.   put "" into newWord                                        -- Initialize our variable
  184.   
  185.   repeat with temp = 1 to (length(theWord))                  -- Repeat for all characters in the word
  186.     if not (puncMarks contains (char temp of theWord)) then  -- If the character isn't punctuation,
  187.       put char temp of theWord after newWord                 -- Copy it over to the new word
  188.     end if
  189.   end repeat
  190.   
  191.   return newWord                                             -- Return our new word, without punctuation
  192.   
  193. end removePunc
  194.  
  195.  
  196. on toggleChannel which                       -- Toggle the visibility of channel "which"
  197.   puppetSprite which,true
  198.   set the visibility of sprite which to (not the visibility of sprite which)
  199.   updateStage
  200.   puppetSprite which,false
  201. end toggleChannel
  202.  
  203.  
  204. on showChannel which                         -- Show the channel "which"
  205.   puppetSprite which,true
  206.   set the visibility of sprite which to true
  207.   --updateStage
  208.   puppetSprite which,false
  209. end showChannel
  210.  
  211.  
  212. on showAllChannels                           -- Show all channels
  213.   repeat with x = 1 to 48
  214.     puppetSprite x,true
  215.     set the visibility of sprite x to true
  216.     puppetSprite x,false
  217.   end repeat
  218. end showAllChannels
  219.  
  220.  
  221. on hideChannel which                         -- Hide the channel "which"
  222.   puppetSprite which,true
  223.   set the visibility of sprite which to false
  224.   --updateStage
  225.   puppetSprite which,false
  226. end hideChannel
  227.  
  228.  
  229. on clearCursors                              -- Will reset the cursor for all sprites to an arrow
  230.   repeat with x = 1 to 48
  231.     set the cursor of sprite x to 0
  232.   end repeat    
  233. end clearCursors
  234.  
  235.  
  236. on clearCursor which                         -- Will reset the cursor for sprite "which" to an arrow
  237.   set the cursor of sprite which to 0
  238. end clearCursor
  239.  
  240.  
  241. on setCursors whichOnes, curs                -- Will set the cursor of sprites "whichOnes" to a hand
  242.   -- Use the form "4,5,6" for whichOnes
  243.   clearCursors
  244.   
  245.   repeat with x = 1 to (the number of items in whichOnes)
  246.     put integer(item x of whichOnes) into i
  247.     set the cursor of sprite i to 5
  248.   end repeat
  249. end setCursors
  250.  
  251.  
  252. on setCursor which, curs                     -- Will set the cursor for sprite "which" to a hand
  253.   set the cursor of sprite which to 5
  254. end setCursor
  255.  
  256.  
  257.